<?php 
 	header("Content-Type:text/html;charset=utf-8");
    include 'includes/init.php';
    include_once 'includes/upload.class.php';
    error_reporting(E_ERROR | E_PARSE);
    session_start();

	if(!empty($_GET['pid'])){
        // 删除
        $sql = "delete from t_product where pid = ".$_GET['pid']." ";
        $query = $db_Obj->query($sql);
        if($query == true ){
        	echo "<script>alert('删除成功!');window.history.go(-1);</script>";
        }
    }
    if (!empty($_POST['pro_type'])) {
        $upObj = new fileup($tarr); 
        $filename = $upObj->up('file_name');
        if ($filename == '') { // 若文件名为空则输出错误信息
            echo 'msg= '.$upObj->geterror();
        }else {
            $_POST['file_name'] = $filename;
        }

        unset($_POST['pro_type']);
        $data = $_POST;
        //  var_dump($data);
        // die();
        $pid = $_POST['pid'];
        $query = $db_Obj->update('t_product', $data, "pid='{$pid}'");
        if($query == true){
            $url = $_SERVER['HTTP_HOST'];
            echo "<script>alert('更新成功!');window.location.href='http://".$url."/prolist.php'</script>";
        }
    }
 ?>